#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
# 　显示存档以及读档画面、保存文件的窗口。
#==============================================================================

class Window_SaveFile < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # 文件名
  attr_reader   :selected                 # 选择状态
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     file_index : 存档文件的索引 (0～3)
  #     filename   : 文件名
  #--------------------------------------------------------------------------
  def initialize(file_index)
    super(640, 64, 160, 416)
    @item_max=12
    self.index=file_index%12
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh(file_index)
    @selected = false
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh(i)
    @file_index=i/12*12
    self.contents.clear
    # 描绘文件编号
    self.contents.font.color = normal_color
    for i in 0...12
      name = "游戏记录#{sprintf("%3d",@file_index + 1 + i)}"
      self.contents.draw_text(0, 32*i, 128, 32, name,1)
    end
    @name_width = contents.text_size(name).width
  end
  #--------------------------------------------------------------------------
  # ● 设置选择状态
  #     selected : 新的选择状态 (true=选择 false=不选择)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
end
